<?php
/**
 * @fileoverview    
 * @author          zhanglei11
 * @date            Feb  02 11:31:49 CST 2012
 * @copyright       sina meila
 */
include_once ('../../__global.php');



class pubfeed extends ml_controller{
    
    private $page;
    private $pagesize = 10;
    
    private $_feedlist;
    private $_contentlist;
    private $_nicks;
    
    
    public function init()
    {
        $this->set_access(self::ACCESS_SELF , self::NOACCESS_REDIRECT );
    }
    public function initParam()
    {
        $this->page = abs((int)$this->input('page' , 'g' , 1));
    }

    public function checkParam()
    {
        
        
    }
    public function main()
    {
        $uid = $this->__visitor['uid'];
        
        
        
        //获得我关注的人的uid
        $oFollow = new ml_model_dbFollow();
        
        $oFollow->getList($uid,0,200);
        $rs = $oFollow->get_data();
        
        foreach($rs as $k => $v) {
            $uidlist[] = $v['follow_uid'];
        }
        
        $uidlist[] = $uid;
        
        $data = array();
        //获取用户名片信息        
        $obizUser = ml_biz_user_getinfo::get_instance();
        $obizUser->initUser($uid,$uid);
        
        $arr = $obizUser->getUserArea();
        $data = array_merge($data,$arr);    // $data 从头到尾没有用啊？
        
        $oFeed = new ml_model_dbPublicFeed();
        $block = ($this->page-1)*3 + 1;
        $rs = $oFeed->getListByUids($uidlist, $block);
        /* 
        if(!$rs)        
            $this->redirect(ML_PAGE_SYSTEM_BUSY);
         */    
        $feed = $oFeed->get_data();
        
        foreach ($feed as $k => $v) {
            if(!empty($v['userfeed_rid']))
                $feed[$k]['rid'] = $v['userfeed_rid'];
            else{
                $feed[$k]['rid'] = 0;
            }
            if(!in_array($v['uid'], $auid))
                $auid[] = $v['uid'];
        }
        
        $htmlModel=new ml_biz_feed_user();
        $Acontent = $htmlModel->output($feed, $this->__visitor['uid']);
        $finnal['content']=$Acontent;
        
        //    找出当前用户信息
        $obizUser = ml_biz_user_getinfo::get_instance();
        $obizUser->initUser($uid,$uid);
        $arr = $obizUser->getUserArea();
        $data = array_merge($data,$arr);
        $data['albums'] = ml_factory::load_standard_conf('op_indexhotalbum');
        $finnal = array_merge($finnal,$data);
             /**
             * @todo 取数字
             */
            
            
        /*     
            $this->_nicks = ml_tool_nick::uids2nicks($aActUid);
            $oBizAtNick = new ml_biz_user_atNick();
             */
        //    获得总数
        
        $rs = $oFeed->getCntByUids($uidlist);
        $cnt = $oFeed->get_data();
        $this->total = isset($cnt[0]) ? $cnt[0] : 0;
        
        
        $last=$this->total['num']-($this->page-1) * ML_FEED_PAGESIZE * 3 <ML_FEED_PAGESIZE?true:false;

        $finnal['albums'] = ml_tool_getdata::mlJsonData('homehotalum','operate');
        $finnal['uid'] = $uid;
        $this->set_scope_var('$totalPage', floor($this->total['num']/(ML_FEED_PAGESIZE * 3)+1));//总页数
        $this->set_scope_var('$currentPage', intval($this->page));//当前页
        $this->set_scope_var('$segment', 1);
        $this->set_scope_var('$lastSegment', $last);
        $this->set_scope_var('$skilltags',$data['skill_tags']);

        $o3rdSer=new ml_model_db3rdService();
        //sina
        $rs=$o3rdSer->get3rdServiceUser($uid,1,$wbInfo);
        $this->set_scope_var('$third_id',$wbInfo['3rd_id']);
         $this->set_scope_var('$weiboAppKey',OPENAPI_WEIBO_APP_KEY);

        $this->set_page_title2('全部');
        $this->page_output('pubfeed' , $finnal);        
    }
}
new pubfeed();
?>